home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / flying-6.11 / cannon.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-30  |  1.7 KB  |  72 lines

  1. #ifndef _global_h
  2. #    include "global.h"
  3. #endif
  4.  
  5. #ifndef _cannon_h
  6. #    include "cannon.h"
  7. #endif
  8. #ifndef _ball_h
  9. #    include "ball.h"
  10. #endif
  11. #ifndef _wall_h
  12. #    include "wall.h"
  13. #endif
  14. #ifndef _graph_h
  15. #    include "graph.h"
  16. #endif
  17. #ifndef _mover_h
  18. #    include "mover.h"
  19. #endif
  20.  
  21. //
  22. // Voreinstellungen
  23. //
  24.  
  25. Cannon::Cannon(double wx, double wy) :
  26. Billard(wx,wy)
  27. {
  28.     w1 = w2 = r = 0;
  29.  
  30.     InitArea( TableWidth, TableHeight );
  31.     SelectTable(-1);
  32.     red_col        = AddBallColor( "red4" );
  33.     white_col    = AddBallColor( "bisque" );
  34.     yellow_col    = AddBallColor( "DarkGoldenrod1" );
  35. }
  36.  
  37. Cannon::~Cannon() {
  38.     if (w1)        delete w1;
  39.     if (w2)        delete w2;
  40.     if (r)        delete r;
  41. }
  42.  
  43. const Real & Cannon::GetNormalBallSize() const {
  44.     return BallRadius;
  45. }
  46.  
  47.  
  48.  
  49. void Cannon::InitPlayground() {
  50.  
  51.     Billard::InitPlayground();
  52.     BallRadius = m->GetActRadius();
  53.     Billard::InitTable();            // Wandbegrenzung
  54.  
  55.     w1 = new Ball( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()/2.0, 0, 0, BallRadius );
  56.     w1->state = new BallState( m, white_col, w1->P() );
  57.     w2 = new Ball( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()/4.0, 0, 0, BallRadius );
  58.     w2->state = new BallState( m, yellow_col, w2->P() );
  59.     r  = new Ball( AreaOffX()+AreaWidth()*0.75, AreaOffY()+AreaHeight()/2.0, 0, 0, BallRadius );
  60.     r->state = new BallState( m, red_col, r->P() );
  61. }
  62.  
  63. void Cannon::DrawBackground() const {
  64.     Billard::DrawBackground();
  65.     SetBgColor(table_line_col);
  66.     FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.25, 1.0 );
  67.     FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.50, 1.0 );
  68.     FillCircle( AreaOffX()+AreaWidth()*0.25, AreaOffY()+AreaHeight()*0.75, 1.0 );
  69.     FillCircle( AreaOffX()+AreaWidth()*0.50, AreaOffY()+AreaHeight()*0.50, 1.0 );
  70.     FillCircle( AreaOffX()+AreaWidth()*0.75, AreaOffY()+AreaHeight()*0.50, 1.0 );
  71. }
  72.